package com.example;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

/**
 * Created by Administrator on 2018/5/15.
 */

public class PhoneNumberResult extends AppCompatActivity {
    private String phnumer;
    private TextView phone;
    private TextView result;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.phoneresult);
        getPhoneNumber();
        initView();
        initResult();
    }

    private void getPhoneNumber() {
        Intent intent =getIntent();
        if(intent!=null){
            Bundle bundle=intent.getExtras();
            if (bundle.containsKey("number")){
                phnumer=bundle.getString("number");
            }
        }
    }
    private void initView() {
        phone=findViewById(R.id.tv_phone);
        result=findViewById(R.id.tv_result);
    }

    private void initResult() {
        phone.setText("您要查询的电话号码："+phnumer);
        if(phnumer.startsWith("180")){
            result.setText("北京");
        }else if (phnumer.startsWith("150")){
            result.setText("天津");
        }else {
            result.setText("未知地区");
        }


    }



}
